package com.dts.yjnb.service.controller.admin;

import com.dts.common.core.controller.BaseController;
import com.dts.common.core.domain.AjaxResult;
import com.dts.yjnb.service.service.IWorkSpaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 首页大屏统计Controller
 *
 * @author dts
 */
@Api(tags = "首页统计相关接口")
@RestController
@RequestMapping("/yjnb/workspace")
@Slf4j
public class WorkSpaceController extends BaseController {

    @Autowired
    private IWorkSpaceService workSpaceService;

    /**
     * 获取首页折线图数据（最近12个月，不包括本月）
     * @return
     */
    @GetMapping("/monthlyLineChart")
    @ApiOperation("获取首页折线图数据（产品中心、农事服务、信贷信息的月度变化，最近12个月不包括本月）")
    public AjaxResult getMonthlyLineChart() {
        log.info("获取首页折线图数据（最近12个月）");
        Map<String, List<Integer>> lineChartData = workSpaceService.getRecent12MonthsLineChartData();
        return AjaxResult.success(lineChartData);
    }

    /**
     * 获取首页柱状图数据
     * @return
     */
    @GetMapping("/barChart")
    @ApiOperation("获取首页柱状图数据（按省份统计）")
    public AjaxResult getBarChartData() {
        log.info("获取首页柱状图数据");
        Map<String, Object> barChartData = workSpaceService.getBarChartData();
        return AjaxResult.success(barChartData);
    }

    /**
     * 获取首页饼图数据
     * @return
     */
    @GetMapping("/pieChart")
    @ApiOperation("获取首页饼图数据（按产品类型统计）")
    public AjaxResult getPieChartData() {
        log.info("获取首页饼图数据");
        List<Map<String, Object>> pieChartData = workSpaceService.getPieChartData();
        return AjaxResult.success(pieChartData);
    }
}
